package com.xgk.boot.module.core.service.truck;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xgk.boot.framework.common.pojo.PageResult;
import com.xgk.boot.framework.common.util.object.BeanUtils;
import com.xgk.boot.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.xgk.boot.module.core.controller.admin.truck.vo.TruckOrderOtherReqVO;
import com.xgk.boot.module.core.controller.admin.truck.vo.TruckOrderReqVO;
import com.xgk.boot.module.core.controller.admin.truck.vo.TruckOrderVO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderAddressDO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderBoxDO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrdersDO;
import com.xgk.boot.module.core.dal.iservice.truck.TruckOrderBoxService;
import com.xgk.boot.module.core.dal.mapper.truck.TruckOrderBoxMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 订单箱子信息 服务实现
 */
@Service
public class TruckOrderBoxServiceImpl extends ServiceImpl<TruckOrderBoxMapper, TruckOrderBoxDO> implements TruckOrderBoxService {


    public PageResult<TruckOrderBoxDO> pageTruckOrders(TruckOrderOtherReqVO orderOtherReqVO){
        if(orderOtherReqVO == null || StrUtil.isBlank(orderOtherReqVO.getOrderCode())){
            return new PageResult<>();
        }
        LambdaQueryWrapperX<TruckOrderBoxDO> boxWrapperX = new LambdaQueryWrapperX<>();
        boxWrapperX.eq(TruckOrderBoxDO::getOrderCode, orderOtherReqVO.getOrderCode());
        boxWrapperX.orderByAsc(TruckOrderBoxDO::getOrderCode).orderByDesc(TruckOrderBoxDO::getCreateTime);
        Page<TruckOrderBoxDO> page=new Page<>(orderOtherReqVO.getCurrent(),orderOtherReqVO.getPageSize());
        Page<TruckOrderBoxDO> pageRes = this.page(page, boxWrapperX);

        return new PageResult<>(pageRes.getRecords(), pageRes.getTotal(), orderOtherReqVO.getCurrent(), orderOtherReqVO.getPageSize());
    }
}